﻿using Nop.Core.ApiDataModel.Logistics;
using Nop.Services.Logistics;
using System.Collections.Generic;
using System.Web.Http;
using System.Web.Http.Description;
using System.Threading.Tasks;

namespace Spotshub.Api.Controllers.V1
{
    [Authorize]
    public class PackagesController : ApiController
    {
        private ILogisticsService _logisticsService;
        public PackagesController(ILogisticsService logisticsService)
        {
            this._logisticsService = logisticsService;
        }

        public IEnumerable<PackageModel> Get()
        {
            return new PackageModel[] { null };
        }

        [ResponseType(typeof(PackageModel))]
        public IHttpActionResult Get(int id)
        {
            var pkg = _logisticsService.GetPackageById(id);
            if (pkg == null)
            {
                return NotFound();
            }

            return Ok(new PackageModel()
            {
                Id = id,
                TrackingNumber = pkg.Shipment.TrackingNumber
            });
        }

        public void Post([FromBody]PackageModel value)
        {
        }

        /// <summary>
        /// Update package
        /// </summary>
        /// <param name="id"></param>
        /// <param name="value"></param>
        public void Put(int id, [FromBody]PackageModel value)
        {
        }

        public void Delete(int id)
        {
        }
    }
}
